package com.iterator.controller.web.marketManager;


import com.iterator.bean.web.pojo.BaseRespVo;
import com.iterator.bean.web.pojo.dhy.Keyword;
import com.iterator.bean.web.dhy.*;
import com.iterator.service.web.marketManager.MallManageService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: DHY
 * @Date: 2021/1/9 16:19
 * @Description: 商场管理  关键词相关
 */
@RestController
@RequestMapping("admin/keyword")
public class KeywordController {
    @Autowired
    MallManageService mallManageService;

    /**
     * 关键字页面显示
     * @param listBO
     * @return
     */
    @GetMapping("list")
    @RequiresPermissions("admin:keyword:list")
    public BaseRespVo showList(KeywordListBO listBO) {
        KeywordListVO listVO= mallManageService.showList(listBO);
        return BaseRespVo.ok(listVO);

    }

    /**
     * 关键字创建
     * @param createBO
     * @return
     */
    @PostMapping("create")
    @RequiresPermissions("admin:keyword:create")
    public BaseRespVo keywordCreate(@RequestBody KeywordCreateBO createBO) {
        KeywordCreateVO keywordCrateVO = mallManageService.keywordCreate(createBO);
        return BaseRespVo.ok(keywordCrateVO);
    }

    /**
     * 关键字删除
     * @param keyword
     * @return
     */
    @PostMapping("delete")
    @RequiresPermissions("admin:keyword:delete")
    public BaseRespVo keywordDelete(@RequestBody Keyword keyword){
        mallManageService.keywordDelete(keyword.getId());
        return BaseRespVo.ok();
    }

    /**
     * 关键字修改
     * @param keyword
     * @return
     */
    @PostMapping("update")
    @RequiresPermissions("admin:keyword:update")
    public BaseRespVo keywordUpdate(@RequestBody Keyword keyword) {
        mallManageService.keywordUpdate(keyword);
        return BaseRespVo.ok(keyword);
    }

}
